<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>{$fields:title/}</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- 使用QLib控件是必须包含样式表 -->
<link type="text/css" rel="stylesheet" href="{$app:qlib}/ui.css" />
<style>
#screen {
width:100%;
height: 600px;
overflow: auto;
background: #000;
color: #cccccc;
}
</style>
<script src='{$app:qlib}/Q.js'>
<!--
import utils.stl;
import utils.json2;
import utils.ajax;
import utils.xml;
import ui.wndx-1-0-2;
//-->
</script>

<script>
<!--

var g_login_window = null;

function loginPanel() {
	g_login_window = new Q.Window({
		title: '管理员登录',
		height: 300,
		width:  400,
		wstyle: ''
	});
	//g_login_window.show (true);
	//var wnd = g_login_window.getwnd();
	g_login_window.setContent("<input>");
	// $GetClient(wnd).innerHTML = "<embed pluginspage='http://www.macromedia.com/go/getflashplayer' src='http://you.video.sina.com.cn/api/sinawebApi/outplayrefer.php/vid=3685396_1292548084_ah21RiZsBjPK+l1lHz2stqkP7KQNt6nki2O2vlasJQZdQ0/XM5GaZNUC4yDQFokbpWFOQpA6dvcg/s.swf' type='application/x-shockwave-flash' name='sinaplayer' allowFullScreen='true' allowScriptAccess='always' width='480' height='370' wmode='transparent'></embed>"

	$FitWindow(g_login_window.getwnd());
	g_login_window.center();
}

function check_login() {
	// 检测是否登陆，没有登陆则弹出登陆对话框
	Q.Ajax({
		command: '{$app:module}&inajax=true&action=check-online',
		oncomplete : function(xmlhttp) {
			//alert(xmlhttp.responseText);
			try	{
				var result = eval('('+xmlhttp.responseText+')');
				if(result.header == 0) {
					if(result.data == 1) {
						alert('ok');
					} else {
						loginPanel();
					}
				}
			} catch (e) {
				alert('parse error'+e+xmlhttp.responseText);
			}
		},

		onerror : function(xmlhttp) {
			alert(xmlhttp.responseText+'\r\n'+e);
		}
	});
}

Q.Ready(function(evt){
	// 检查是否已经登录
	check_login()
    Q.$('input-command').focus();
    Q.$('form1').onsubmit = function(evt) {
		var command = Q.$('input-command').value;
		Q.$('screen').innerHTML += 'admin>'+command + '<br/>';
		Q.$('input-command').value = '';
		if(command != "") {
		  Q.Ajax({
			command: '{$app:module}&inajax=true&action=execute',
			data : { cmd: command },
			oncomplete : function(xmlhttp) {
				//alert(xmlhttp.responseText);
				try	{
					var result = eval('('+xmlhttp.responseText+')');
					Q.$('screen').innerHTML += result.data.replace(/\n/g,"<br />")+"<br/>";
				} catch (e) {
					Q.$('screen').innerHTML += xmlhttp.responseText.replace(/\n/g,"<br />")+'<br/>';
				}
				
				Q.$('screen').scrollTop = Q.$('screen').scrollHeight;				
				Q.$('input-command').value = '';
			},

			onerror : function(xmlhttp) {
				
			}
		  });
		}
		return false;
    }
});
//-->
</script>
<body onselectstart="return false" style="background: #000;color:white;height:100%;margin:0;">
<form id="form1">

----------------------------------------------------------------<br/>
<h3 style="color:white;line-height:20px;">welcome to PHPkind command：</h3>
================================================================<br/>
<!--
{ $app:name/}<br>
{ $theme:path}<br>
{ $cfg:dbs.default.type/}<br/>
{ $app:root}<br/>
{ $app:app}<br/>
{ $app:module}<br/>
-->
<div id="screen">
</div>
<input id="input-command" type="text" style="width:500px; background: #000; color:white;border-width:0;">
</form>
</body>
</html>
